<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        // \Illuminate\Support\Facades\DB::listen(function (QueryExecuted $query) {
        //     if ($query->bindings) {
        //         $sql = $query->sql;
        //         foreach ($query->bindings as $val) {
        //             if (is_string($val)) {
        //                 $val = "\"" . strval($val) . "\"";
        //             }
        //             $sql = $this->str_replace_once("?", $val, $sql);
        //         }
        //         Log::debug($sql, $query->bindings);
        //     } else {
        //         Log::debug($query->sql, $query->bindings);
        //     }

        // });
    }
    
    /**
     * @param $needle
     * @param $replace
     * @param $haystack
     * @return mixed
     */
    // private function str_replace_once($needle, $replace, $haystack)
    // {
    //     $pos = strpos($haystack, $needle);
    //     if ($pos === false) {
    //         return $haystack;
    //     }
    //     return substr_replace($haystack, $replace, $pos, strlen($needle));
    // }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
